package com.taotao.manager.controller;

import com.taotao.common.pojo.EasyUiTreeNode;
import com.taotao.common.pojo.TaotaoResult;
import com.taotao.content.service.ContentCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class ContentCategoryController {
    @Autowired
    private ContentCategoryService contentCategoryService;

    @RequestMapping(value = "/content/category/list",method = RequestMethod.GET)
    @ResponseBody
    public List<EasyUiTreeNode> getContentCategoryList(@RequestParam(value = "id",defaultValue = "0") Long parentId) {
        List<EasyUiTreeNode> list = contentCategoryService.getContentCategoryList(parentId);
        return list;
    }

    @RequestMapping(value = "/content/category/create",method = RequestMethod.POST)
    @ResponseBody
    public TaotaoResult createContentCategoryList(@RequestParam(defaultValue = "0") Long parentId,String name) {
        TaotaoResult result = contentCategoryService.createContentCategory(parentId, name);
        return result;
    }

    @RequestMapping(value = "/content/category/update",method = RequestMethod.POST)
    @ResponseBody
    public TaotaoResult updateContentCategoryList(Long id,String name) {
        TaotaoResult result = contentCategoryService.updateContentCategory(id, name);
        return result;
    }
    @RequestMapping(value = "/content/category/delete",method = RequestMethod.POST)
    @ResponseBody
    public TaotaoResult deleteContentCategory(Long id) {
        TaotaoResult result = contentCategoryService.deleteContentCategory(id);
        return result;
    }


}
